package basicConcepts;

public class TypeCastingParentAndChild {
	private static class Parent {
		public void parentMethod() {
			System.out.println("TestConceptsParentChild.Parent.parentMethod()");

		}
	}

	private static class Child extends Parent {
		public void parentMethod() {
			System.out.println("TestConceptsParentChild.Child.parentMethod()");
		}
	}

	public static void main(String[] args) {
		Child child = new Child();
		Parent parent = new Parent();

		/*
		 * if child object has to refer to parent object then parent object must
		 * be type casted to child object's class
		 */
		child = (Child) parent;
		
		/*
		 * if parent object has to refer to child object then child object need not
		 * be type casted to parent object's class
		 */
		parent = child;

	}

}
